﻿using Sunny.UI;
using System.Collections.Generic;

namespace CoreShop.App
{
    public partial class UIAddFoods : UIDropDownItem
    {
        public UIAddFoods()
        {
            InitializeComponent();
        }

        private void uiSymbolLabel2_Click(object sender, System.EventArgs e)
        {
            Close();
        }

        public void AddType(string type)
        {
            UIMenuItemSeparator item = new UIMenuItemSeparator(type, 40);
            item.SetOtherMode();
            uiFlowLayoutPanel2.Add(item);
        }

        public void AddFoods(UAddFoodItemInfo info)
        {
            UIAddFoodsItem item = new UIAddFoodsItem();
            item.Type = info.Type;
            item.Food = info.Food;
            item.Money = info.Money;
            item.Count = info.Count;
            uiFlowLayoutPanel2.Add(item);
        }

        private void uiButton23_Click(object sender, System.EventArgs e)
        {
            List<UAddFoodItemInfo> infos = new List<UAddFoodItemInfo>();
            foreach (var ctrl in this.GetControls<UIAddFoodsItem>(true))
            {
                if (ctrl.Count > 0)
                    infos.Add(new UAddFoodItemInfo(ctrl.Type, ctrl.Food, ctrl.Money, ctrl.Count, ctrl.Tag));
            }

            DoValueChanged(this, infos.ToArray());
            Close();
        }
    }
}
